package com.lldpet.spring.cloud.demo.stream.consumer.demo.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @desc：MQMessageListener
 * @author: guanliang.xue
 * @date: 2021/5/11 17:15
 * @version:
 * @since:
 */
@Component
@EnableBinding(Sink.class)
public class MqMessageListener {

    private static final Logger logger = LoggerFactory.getLogger(MqMessageListener.class);

    @Value("${server.port}")
    private String serverPort;

    @StreamListener(Sink.INPUT)
    public void input(Message<String> message){
        logger.info("message#getPayload: {}, port: {}",message.getPayload(),serverPort);
    }

}
